package com.example.order.controller;

import com.example.order.dto.OrderDTO;
import com.example.order.message.StareamClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class SendMessageController {

    @Autowired
    private StareamClient stareamClient;

    @RequestMapping("/sendMessage")
    public String process(){
        String msg = "now==="+new Date();
        Boolean send = stareamClient.input().send(MessageBuilder.withPayload(msg).build());
        return send.toString();
    }
    @RequestMapping("/sendDto")
    public String sendDto(){
        OrderDTO orderDTO = new OrderDTO();
        orderDTO.setOrderId("54545454");
        Boolean send = stareamClient.input().send(MessageBuilder.withPayload(orderDTO).build());
        return send.toString();
    }
}
